Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE ember-application-engines] Initial extraction of engines from applications #12685

Merged
merged 10 commits into from
Dec 8, 2015

Conversation

dgeb
Copy link
Member

@dgeb dgeb commented Dec 5, 2015

This initial PR for engines follows the strategy proposed in the Engines RFC.

It introduces a base class, Engine, which is wholly extracted from (and then extended by) Application. Similarly, EngineInstance has been wholly extracted from (and then extended by) ApplicationInstance.

The Engine base class is now responsible for maintaining a registry and initializers.

The EngineInstance base class is now responsible for maintaining an instance-level registry and container.

Ember.Engine is only exposed when the new ember-application-engines feature flag is enabled.

The APIs and behavior of Application and ApplicationInstance remain identical, as do tests and documentation.

Some tests of extracted behavior were duplicated for engines, but the original tests for applications were kept in place. Any test duplication should be revisited before the feature flag is enabled.

The primary purpose of this PR is to allow for further experimentation with engines in an addon. It will also allow behavior to be folded into ember core gradually as experimentation proceeds.

@@ -83,24 +79,20 @@ let ApplicationInstance = EmberObject.extend(RegistryProxy, ContainerProxy, {
rootElement: null,

init() {
this._super(...arguments);
let application = get(this, 'application');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interacting with this before super() in a constructor is not compatible with ES6 classes, fwiw. If this can be differently factored, I think that would be ideal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @mixonic. I was able to refactor it such that the engine instance is aware that application might be set instead of base (i.e. if base is not set, then application is checked). if others agree that base is general enough to specify the base class for both engine and application instances, we can consider deprecating the application property at some point.

@kiwiupover
Copy link
Contributor

Thanks for your work on this @dgeb Cheers

@uses ContainerProxyMixin
*/

let EngineInstance = EmberObject.extend(RegistryProxy, ContainerProxy, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

@dgeb
Copy link
Member Author

dgeb commented Dec 6, 2015

@stefanpenner thanks for the review. I've just revised as per your suggestions, with the two exceptions:

  • Need to refactor registry.set = set;. Probably best in a separate PR since it's a change to current behavior.
  • Need to consider whether to deprecate usage of the application property in favor of base. For now, the EngineInstance accepts either as valid, so ApplicationInstance does as well.

@rwjblue thoughts?

Ember.Engine = Engine;

// Expose EngineInstance for easy overriding. Reanalyze whether to
// continue exposing it after feature flag is removed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we should likely remove it. ApplicationInstance is not exposed at all, so we should follow that (or expose it as well).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated exposing ApplicationInstance here as well - maybe we should for consistency and then remove both after the feature flag is removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care which way we go, but we need to be consistent. Either both are exposed, or neither are...

@rwjblue
Copy link
Member

rwjblue commented Dec 8, 2015

The doc strings for Ember.Application need to be updated to properly mark that it @extends Ember.Engine (other wise the docs moved simply "vanish"). Same for Ember.EngineInstance.

return properties;
}

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a small description here? This is the header page that shows up for the class in our API docs...

@dgeb
Copy link
Member Author

dgeb commented Dec 8, 2015

The doc strings for Ember.Application need to be updated to properly mark that it @extends Ember.Engine (other wise the docs moved simply "vanish"). Same for Ember.EngineInstance.

@rwjblue Good catch. I just updated @extends for Application. I think ApplicationInstance and EngineInstance are correct though (but let me know).

@rwjblue
Copy link
Member

rwjblue commented Dec 8, 2015

I think ApplicationInstance and EngineInstance are correct though (but let me know).

Confirm.

dgeb added 10 commits December 7, 2015 22:19
…n to Engine.

Initializers and instance initializers are a common concern for
applications and engines.
…ncerns for engines.

Provide a spare base implementation of `buildRegistry` for `Engine`,
which is extended by `Application`.

Also, allow for a custom `Resolver` property on `Engine` (and by
extension, `Application`).
…tialization for engine instances.

Move registry and container creation from `ApplicationInstance` to
`EngineInstance`.
Only expose `Ember.Engine` when feature flag is enabled.
Replicate appropriate tests from applications. We don’t want to yet move
tests while engines are feature flagged and in flux.
Replicate appropriate tests from application instances. We don’t want to
yet move tests while engines are feature flagged and in flux.
…mber.ApplicationInstance.

Expose Ember.EngineInstance and Ember.ApplicationInstance for
easy overriding. Need to reanalyze whether to continue exposing
them after feature flag is removed.
@dgeb
Copy link
Member Author

dgeb commented Dec 8, 2015

@rwjblue I've added a brief description for Engine and exposed Ember.ApplicationInstance alongside Ember.EngineInstance (just while feature flagged).

Thanks for the review - let me know if I've overlooked any other suggestions.

rwjblue added a commit that referenced this pull request Dec 8, 2015
[FEATURE ember-application-engines] Initial extraction of engines from applications
@rwjblue rwjblue merged commit 192fceb into emberjs:master Dec 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants